#
# Great Statesman Mod
# CvGreatStatesmanEventManager
# 

from CvPythonExtensions import *
import CvUtil

import CvEventManager
import sys
import PyHelpers
import CvMainInterface
import CvConfigParser

gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo

# Change the value to false if the religion of the inquisitor should not be 
# required to be present at the city where an inquisition should be started.
# Default value is True
g_bRequireStateReligionForReligionRemoval = True

# Change the value to false if the state religion of the owner of the target 
# city should not match the state religion of the owner of the inquisitor unit 
# to start an inquisition at the target city.
# Default value is True
g_bRequireCityOwnerStateReligionMatchForReligionRemoval = True

# Change the value to false if inquisitors should be able to remove religions
# from any city they can enter.
# Default value is True
g_bRequireOpenBordersForReligionRemoval = True

# globals
###################################################
class CvInquisitionEventManager:
	def __init__(self, eventManager):
		# initialize base class

		
		global g_bRequireStateReligionForReligionRemoval
		global g_bRequireCityOwnerStateReligionMatchForReligionRemoval
		global g_bRequireOpenBordersForReligionRemoval

		config = CvConfigParser.CvConfigParser("Inquisition Mod Config.ini")
		
		# Read the configuration values for the great statesman
		if(config != None):
			g_bRequireStateReligionForReligionRemoval = config.getboolean("Inquisition Mod", "Require State Religion For Religion Removal", true)
			g_bRequireCityOwnerStateReligionMatchForReligionRemoval = config.getboolean("Inquisition Mod", "Require City Owner State Religion Match For Religion Removal", true)
			g_bRequireOpenBordersForReligionRemoval = config.getboolean("Inquisition Mod", "Require Open Borders For Religion Removal", true)

			gc.getGame().setRequireStateReligionForReligionRemoval(g_bRequireStateReligionForReligionRemoval)
			gc.getGame().setRequireCityOwnerStateReligionMatchForReligionRemoval(g_bRequireCityOwnerStateReligionMatchForReligionRemoval)			
			gc.getGame().setRequireOpenBordersForReligionRemoval(g_bRequireOpenBordersForReligionRemoval)			
			
			

#		eventManager.addEventHandler("mouseEvent", self.onMouseEvent)


	def onMouseEvent(self, argsList):
		'mouse handler - returns 1 if the event was consumed'
		eventType,mx,my,px,py,interfaceConsumed,screens = argsList
		

		objPlot = gc.getMap().plot(px,py)
		if(objPlot != None):
			objUnit = objPlot.getUnit(0)
			
			if(objUnit != None):
				CyInterface().addImmediateMessage("%s" %(objUnit.canRemoveReligion(objPlot, true)),"")				
				
